#!/usr/local/bin/python
import sys
import os
sys.path.append("/usr/local/oms")
sys.path.append("/usr/local/django")
os.environ["DJANGO_SETTINGS_MODULE"]="oms.settings"
if len(sys.argv) > 1:
    method = sys.argv[1]
    args = sys.argv[2:]
    module_name = str(".".join(method.split(".")[:-1]))
    method_name = str(method.split(".")[-1])
    module = __import__("oms.apps."+module_name,None,None,[module_name])
    method_instance = getattr(module,method_name)
    if len(args) > 0:
        method_instance(*args)
    else:
        method_instance()
else:
    print "An api function name must be passed as first argument"
